﻿@model CommentMainModel
@{
    ResLink.AddCss("~/res/css/comment.css");    
}   

<hr />

<div class="controls pull-right">
    <a onclick="덧글입력상자_보이기(0, '')" class="btn btn-small">한줄 덧글 작성</a>
</div>

<h2>한줄 덧글</h2>

<div id="덧글목록">
</div>

<form id="덧글목록갱신">
    @Html.HiddenFor(m => m.대상구분)
    @Html.HiddenFor(m => m.대상ID)
</form>

<div id="덧글입력상자" class="modal hide" tabindex="-1" role="dialog" >
    <div class="modal-header">
        <a class="close" data-dismiss="modal">&times;</a>
        <h3>한줄 덧글</h3>
    </div>

    <div class="modal-body">
        <form id="덧글저장">
            <textarea name="내용"></textarea>
            <input type="hidden" name="덧글ID" />
            @Html.HiddenFor(m => m.대상구분)
            @Html.HiddenFor(m => m.대상ID)
        </form>
    </div>

    <div class="modal-footer">
        <button class="btn btn-primary" data-dismiss="modal" onclick="덧글저장()">저장</button>
        <button class="btn" data-dismiss="modal">취소</button>
  </div>
</div>

<script type="text/javascript">
    $(function () {
        덧글목록_갱신();
    });

    function 덧글목록_갱신() {
        AjaxLoad('@Url.MyAction("List", "Comment")', $("form#덧글목록갱신").serialize(),  $("#덧글목록"));
    }

    function 덧글입력상자_보이기(덧글ID, 내용) {
        $('#덧글입력상자 input[name=덧글ID]').val(덧글ID);
        $('#덧글입력상자 textarea').val(내용);
        $('#덧글입력상자').modal('show');
    }

    function 덧글저장() {
        AjaxPost('@Url.MyAction("Save", "Comment")', $("form#덧글저장").serialize(), null, 덧글목록_갱신);
    }

    function 덧글삭제(덧글ID) {
        AjaxPost('@Url.MyAction("Delete", "Comment")', { ID: 덧글ID }, "삭제하시겠습니까?", 덧글목록_갱신);
    }
</script>
